<template>
  <div class="capital-page">
    <div class="router-content">
      <div v-if="pageType == 'list'">
        <!-- // 查询栏    -->
        <el-form inline style="text-align: left">
          <el-form-item
            label="资方名称"
            inline
            style="width: 300px; marginright: 20px"
          >
            <el-input v-model="queryForm.funderName" />
          </el-form-item>
          <el-form-item
            label="状态"
            inline
            style="width: 300px; marginright: 20px"
          >
            <el-select v-model="queryForm.state" label-in-value>
              <el-option
                v-for="item in seletOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="所在地"
            inline
            style="width: 300px; marginright: 20px"
          >
            <el-cascader
              clearable
              :disabled="pageType == 'details'"
              size="large"
              :options="options"
              v-model="queryAddress"
              @change="queryAddressChange"
            >
            </el-cascader>
          </el-form-item>
          <el-form-item
            label="联系电话"
            inline
            style="width: 300px; marginright: 20px"
          >
            <el-input v-model="queryForm.contactNumber" />
          </el-form-item>
          <el-form-item label="操作时间" inline>
            <el-date-picker
              @change="timeChange"
              v-model="timeRange"
              type="datetimerange"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              :default-time="['00:00:00']"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item inline style="marginright: 20px">
            <el-button
              style="background: rgb(11, 78, 158); color: rgb(255, 255, 255)"
              class="query-btn"
              @click="handleQueryClick('search')"
              >查询</el-button
            >
            <el-button
              class="query-btn"
              style="color: rgb(0, 0, 0)"
              @click="handleQueryClick('reset')"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
        <div style="margin-bottom: 20px">
          <el-button
            icon="el-icon-plus"
            v-if="add"
            type="primary"
            @click="addList"
            >新增资方</el-button
          >
        </div>
        <el-table :data="tableData" style="width: 100%" border>
          <el-table-column type="index" label="序号" width="50">
            <template slot-scope="scope">{{
              10 > scope.$index + 1
                ? "0" + (scope.$index + 1)
                : scope.$index + 1
            }}</template>
          </el-table-column>
          <el-table-column prop="funderName" label="资方名称"></el-table-column>
          <el-table-column
            prop="loanAmount"
            label="出借金额（万元）"
          ></el-table-column>
          <el-table-column label="所在地">
            <template slot-scope="scope">{{
              scope.row.provinceName +
              "-" +
              scope.row.cityName +
              (scope.row.districtName == null
                ? ""
                : "-" + scope.row.districtName)
            }}</template>
          </el-table-column>
          <el-table-column
            prop="contactPerson"
            label="联系人"
          ></el-table-column>
          <el-table-column
            prop="contactNumber"
            label="联系电话"
          ></el-table-column>
          <el-table-column prop="state" label="状态">
            <template slot-scope="scope">
              {{
                scope.row.state == 1
                  ? "进行中"
                  : scope.row.state == 2
                  ? "已完成"
                  : scope.row.state == 3
                  ? "已撤回"
                  : ""
              }}
            </template>
          </el-table-column>

          <el-table-column prop="createName" label="操作人"></el-table-column>
          <el-table-column prop="updateTime" label="操作时间">
            <template slot-scope="scope">
              {{ scope.row.updateTime | formatTime }}
            </template>
          </el-table-column>
          <el-table-column label="操作" :width="188">
            <template slot-scope="scope">
              <el-tag
                v-if="query"
                @click="handleOptions({ key: '1', index: scope.$index })"
                size="medium"
                style="margin: 0 5px 5px 0; cursor: pointer"
                >详情</el-tag
              >
              <el-tag
                v-if="scope.row.state != 2 && edit"
                @click="handleOptions({ key: '2', index: scope.$index })"
                size="medium"
                style="margin: 0 5px 5px 0; cursor: pointer"
                >编辑</el-tag
              >
              <el-tag
                v-if="scope.row.state != 3 && revoke"
                @click="handleOptions({ key: '3', index: scope.$index })"
                size="medium"
                style="margin: 0 5px 5px 0; cursor: pointer"
                >撤回</el-tag
              >
              <el-tag
                v-if="del"
                @click="handleOptions({ key: '4', index: scope.$index })"
                size="medium"
                style="margin: 0 5px 5px 0; cursor: pointer"
                >删除</el-tag
              >
              <el-tag
                v-if="scope.row.state == 1 && update"
                @click="handleOptions({ key: '5', index: scope.$index })"
                size="medium"
                style="margin: 0 5px 5px 0; cursor: pointer"
                >更新状态</el-tag
              >
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          style="margin-top: 50px"
          @current-change="handlePageChange"
          :current-page="pageParams.pageNum"
          :page-sizes="[pageParams.pageSize]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="count"
        ></el-pagination>
      </div>
      <div v-else>
        <div
          class="form"
          v-if="
            pageType == 'add' || pageType == 'edit' || pageType == 'details'
          "
        >
          <el-form
            label-width="120px"
            :model="formModel"
            :rules="formRules"
            ref="formModel"
            style="width: 80%; margin: 32px auto"
          >
            <el-form-item label="资方名称" prop="funderName">
              <el-input
                :disabled="pageType == 'details'"
                maxlength="64"
                v-model="formModel.funderName"
                placeholder="请输入资方名称"
              ></el-input>
            </el-form-item>
            <el-form-item label="资方LOGO" prop="funderLogo">
              <el-upload
                accept=".png, .jpeg, .jpg, .gif"
                action
                :disabled="pageType == 'details'"
                :http-request="uploadOss"
                :show-file-list="false"
                :before-upload="handleBeforeUpload"
              >
                <div v-if="formModel.funderLogo">
                  <img :src="formModel.funderLogo" class="avatar" />
                </div>
                <div v-else class="notImg">
                  <i class="el-icon-plus avatar-uploader-icon"></i>
                  <span>上传LOGO图</span>
                </div>
              </el-upload>
              <p style="color: #666">
                仅支持png、jpg、gif、jpeg格式，不超过2m（尺寸比列4：3)
              </p>
            </el-form-item>
            <el-form-item label="所在地" required>
              <el-cascader
                :disabled="pageType == 'details'"
                size="large"
                :options="options"
                v-model="selectedOptions"
                @change="handleChange"
              >
              </el-cascader>
            </el-form-item>
            <el-form-item label="资方类型" prop="funderType">
              <el-select
                :disabled="pageType == 'details'"
                v-model="formModel.funderType"
                placeholder="请选择资方类型"
              >
                <el-option label="银行" value="银行"></el-option>
                <el-option label="基金公司" value="基金公司"></el-option>
                <el-option
                  label="民间投资机构"
                  value="民间投资机构"
                ></el-option>
                <el-option label="其他" value="其他"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="出借额度" type="number" prop="loanAmount">
              <el-input
                @keyup.native="adjustMaxLen($event)"
                :disabled="pageType == 'details'"
                maxlength="16"
                v-model="formModel.loanAmount"
                placeholder="请输入出借额度"
                ><template slot="append">万元</template></el-input
              >
            </el-form-item>
            <el-form-item label="期限许可" prop="loanPeriod">
              <el-input
                :disabled="pageType == 'details'"
                maxlength="16"
                v-model="formModel.loanPeriod"
                placeholder="请输入期限许可"
              ></el-input>
            </el-form-item>
            <el-form-item label="出借类型" prop="loanMethod">
              <el-radio-group
                @change="radioChange"
                v-model="formModel.loanMethod"
                :disabled="pageType == 'details'"
              >
                <el-radio :label="1">股权投资</el-radio>
                <el-radio :label="2">债权投资</el-radio>
                <el-radio :label="3">其他</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item
              label="收益方式"
              prop="incomeMethod"
              v-show="formModel.loanMethod == 1 || !formModel.loanMethod"
            >
              <el-input
                :disabled="pageType == 'details'"
                maxlength="16"
                v-model="formModel.incomeMethod"
                placeholder="请输入收益方式"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="退出方式"
              prop="exitMethod"
              v-show="formModel.loanMethod == 1 || !formModel.loanMethod"
            >
              <el-select
                :disabled="pageType == 'details'"
                v-model="formModel.exitMethod"
                placeholder="请选择退出方式"
              >
                <el-option label="抵押担保" value="抵押担保"></el-option>
                <el-option label="股权质押" value="股权质押"></el-option>
                <el-option label="股票质押" value="股票质押"></el-option>
                <el-option label="债务偿还" value="债务偿还"></el-option>
                <el-option label="其他" value="其他"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="资金利率"
              prop="incomeMethod"
              v-show="formModel.loanMethod == 2"
            >
              <el-input
                :disabled="pageType == 'details'"
                maxlength="8"
                v-model="formModel.incomeMethod"
                placeholder="请输入资金利率"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="还款方式"
              prop="exitMethod"
              v-show="formModel.loanMethod == 2"
            >
              <el-select
                :disabled="pageType == 'details'"
                v-model="formModel.exitMethod"
                placeholder="请选择还款方式"
              >
                <el-option label="随借随还" value="随借随还"></el-option>
                <el-option label="净息还款" value="净息还款"></el-option>
                <el-option label="先本后息" value="先本后息"></el-option>
                <el-option label="先息后本" value="先息后本"></el-option>
                <el-option label="等额本金" value="等额本金"></el-option>
                <el-option label="等额本息" value="等额本息"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="其他" v-show="formModel.loanMethod == 3">
              面议
            </el-form-item>

            <el-form-item label="资金属性" prop="funderAttribute">
              <el-select
                :disabled="pageType == 'details'"
                v-model="formModel.funderAttribute"
                placeholder="请选择资金属性"
              >
                <el-option label="个人资金" value="个人资金"></el-option>
                <el-option label="企业资金" value="企业资金"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="资方简介" prop="funderIntroduction">
              <el-input
                :disabled="pageType == 'details'"
                v-model="formModel.funderIntroduction"
                type="textarea"
                :autosize="{ minRows: 5, maxRows: 7 }"
                maxlength="2000"
                placeholder="请输入2000字内资方简介"
              ></el-input>
            </el-form-item>
            <el-form-item label="资料要求" prop="requestInformation">
              <el-input
                :disabled="pageType == 'details'"
                v-model="formModel.requestInformation"
                type="textarea"
                :autosize="{ minRows: 5, maxRows: 7 }"
                maxlength="2000"
                placeholder="请输入2000字内资料要求"
              ></el-input>
            </el-form-item>
            <el-form-item label="联系人" prop="contactPerson">
              <el-input
                :disabled="pageType == 'details'"
                maxlength="16"
                v-model="formModel.contactPerson"
                placeholder="请输入联系人"
              ></el-input>
            </el-form-item>
            <el-form-item label="联系电话" prop="contactNumber">
              <el-input
                :disabled="pageType == 'details'"
                maxlength="11"
                v-model="formModel.contactNumber"
                placeholder="请输入联系电话"
              ></el-input>
            </el-form-item>
            <el-form-item label>
              <el-button
                v-if="pageType != 'details'"
                type="primary"
                @click="submitForm('formModel')"
                :loading="$store.state.subLoading"
                >提交</el-button
              >
              <el-button
                v-if="pageType != 'details'"
                @click="closeForm('formModel')"
                >取消</el-button
              >
              <el-button
                v-if="pageType == 'details'"
                type="primary"
                @click="pageType = 'list'"
                :loading="$store.state.subLoading"
                >返回</el-button
              >
            </el-form-item>
          </el-form>
        </div>
      </div>
      <Modal
        :title="
          modalType == 'del'
            ? '删除确认'
            : modalType == 'revoke'
            ? '撤回确认'
            : modalType == 'finish'
            ? '完结确认'
            : ''
        "
        :dialogVisible="visible"
        :loading="$store.state.subLoading"
        @handleClose="handleCancel"
        @handleConfirm="handleConfirm"
        width="600px"
      >
        <div v-if="modalType == 'del'">
          <i
            class="el-icon-warning"
            style="color: #faad14; font-size: 18px; margin: 0 20px"
          ></i
          >确认要删除该项目吗？
        </div>
        <div v-else-if="modalType == 'revoke'">
          <i
            class="el-icon-warning"
            style="color: #faad14; font-size: 18px; margin: 0 20px"
          ></i
          >确认要撤回该项目吗？
        </div>
        <div v-else>
          <i
            class="el-icon-warning"
            style="color: #faad14; font-size: 18px; margin: 0 20px"
          ></i
          >确认要完结该项目吗？
        </div>
      </Modal>
    </div>
  </div>
</template>
<script>
import Modal from "@/components/common/Modal.vue";
import api from "@/api/modules/service/capital.js";
import { regionData, CodeToText, TextToCode } from "element-china-area-data";
import util from "@/utils";
import setToken from "@/utils/auth";
export default {
  name: "Capital",
  components: { Modal },
  data() {
    return {
      query: true,
      add: true,
      edit: true,
      revoke: true,
      del: true,
      update: true, //按钮权限
      options: regionData,
      selectedOptions: [],
      queryAddress: [],
      pageType: "list",
      modalType: "",
      visible: false,
      queryForm: {
        funderName: "",
        provinceName: "",
        cityName: "",
        districtName: "",
        contactNumber: "",
        state: "",
        startTime: "",
        endTime: "",
      },
      timeRange: [],
      seletOptions: [
        {
          value: "",
          label: "全部",
        },
        {
          value: "1",
          label: "进行中",
        },
        {
          value: "2",
          label: "已完成",
        },
        {
          value: "3",
          label: "已撤回",
        },
      ],
      currentRow: "",
      tableData: [],
      count: 0,
      pageParams: {
        pageNum: 1,
        pageSize: 10,
      },

      formModel: {
        funderName: "",
        funderLogo: "",
        provinceName: "",
        cityName: "",
        districtName: "",
        funderType: "",
        loanAmount: "",
        loanPeriod: "",
        loanMethod: "",
        incomeMethod: "",
        exitMethod: "",
        funderAttribute: "",
        funderIntroduction: "",
        requestInformation: "",
        contactPerson: "",
        contactNumber: "",
      },
      formRules: {
        funderName: [
          { required: true, message: "请输入资方名称", trigger: "blur" },
        ],
        funderLogo: [{ message: "请上传资方logo", trigger: "blur" }],
        funderType: [
          { required: true, message: "请选择资方类型", trigger: "change" },
        ],

        loanAmount: [
          { required: true, message: "请输入出借额度", trigger: "blur" },
        ],
        loanPeriod: [
          { required: true, message: "请选择期限许可", trigger: "blur" },
        ],
        loanMethod: [
          { required: true, message: "请选择出借类型", trigger: "change" },
        ],
        incomeMethod: [
          {
            required: true,
            message: "请输入收益方式",
            trigger: ["change", "blur"],
          },
        ],
        exitMethod: [
          {
            required: true,
            message: `请选择退出方式`,
            trigger: ["change", "blur"],
          },
        ],
        funderAttribute: [
          {
            required: true,
            message: "请选择资金属性",
            trigger: ["change", "blur"],
          },
        ],
        funderIntroduction: [
          { required: true, message: "请输入资方简介", trigger: "blur" },
        ],
        requestInformation: [
          { required: true, message: "请填写资料要求", trigger: "blur" },
        ],

        contactPerson: [
          { required: true, message: "请输入联系人姓名", trigger: "blur" },
        ],
        contactNumber: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
          {
            pattern: /^1([3456789])\d{9}$/,
            message: "请输入正确的手机号",
            trigger: "blur",
          },
        ],
      },
    };
  },
  mounted() {
    this.$nextTick(() => {
      // 设置页面按钮权限
      let btns = this.$store.state.userInfo.list[3].children[1];
      this.query = btns.children[0].havePermission;
      this.add = btns.children[1].havePermission;
      this.edit = btns.children[2].havePermission;
      this.revoke = btns.children[3].havePermission;
      this.del = btns.children[4].havePermission;
      this.update = btns.children[5].havePermission;
      this.getData(this.pageParams);
    });
  },
  methods: {
    getData(params) {
      try {
        api
          .getServiceFunderPage(
            params ? params : { ...this.pageParams, ...this.queryForm }
          )
          .then((res) => {
            this.tableData = res.data;
            this.count = +res.count;
            this.pageType = "list";
          });
      } catch (error) {
        console.log(error);
      }
      this.modalType = "";
      this.visible = false;
    },
    handlePageChange(val) {
      this.pageParams.pageNum = val;
      this.getData({ ...this.pageParams, ...this.queryForm });
    },
    handleQueryClick(val) {
      switch (val) {
        case "search":
          this.pageParams.pageNum = 1;
          this.getData({ ...this.pageParams, ...this.queryForm });
          break;
        case "reset":
          Object.keys(this.queryForm).forEach((item) => {
            this.queryForm[item] = "";
          });
          this.timeRange = [];
          this.queryAddress = [];
          this.pageParams.pageNum = 1;
          this.getData(this.pageParams);
          break;
      }
    },
    timeChange() {
      if (this.timeRange.length) {
        this.queryForm.startTime = util.formatTime(this.timeRange[0]);
        this.queryForm.endTime = util.formatTime(this.timeRange[1]);
      } else {
        this.queryForm.startTime = "";
        this.queryForm.endTime = "";
      }
    },
    queryAddressChange(value) {
      if (!value.length) {
        this.queryForm.provinceName =
          this.queryForm.cityName =
          this.queryForm.districtName =
            "";
      } else {
        this.queryForm.provinceName = CodeToText[`${value[0]}`];
        this.queryForm.cityName = CodeToText[`${value[1]}`];
        this.queryForm.districtName = CodeToText[`${value[2]}`];
      }
    },
    handleOptions(val) {
      const { key, index } = val;
      this.currentRow = this.tableData[index];
      switch (key) {
        case "1":
          api
            .getServiceFunder({ funderId: this.currentRow.funderId })
            .then((res) => {
              Object.keys(this.formModel).forEach((item) => {
                this.formModel[item] = res.data[item];
              });
              // 地址转code码
              this.selectedOptions = [
                TextToCode[`${this.formModel.provinceName}`].code,
                TextToCode[`${this.formModel.provinceName}`][
                  `${this.formModel.cityName}`
                ].code,
                TextToCode[`${this.formModel.provinceName}`][
                  `${this.formModel.cityName}`
                ][`${this.formModel.districtName}`].code,
              ];
              // 组装融资方式

              this.formModel.loanMethod = this.formModel.loanMethod.includes(
                ","
              )
                ? +this.formModel.loanMethod.split(",")[0]
                : +this.formModel.loanMethod;

              this.pageType = "details";
            });

          break;
        case "2":
          api
            .getServiceFunder({ funderId: this.currentRow.funderId })
            .then((res) => {
              Object.keys(this.formModel).forEach((item) => {
                this.formModel[item] = res.data[item];
              });
              // 地址转code码
              this.selectedOptions = [
                TextToCode[`${this.formModel.provinceName}`].code,
                TextToCode[`${this.formModel.provinceName}`][
                  `${this.formModel.cityName}`
                ].code,
                TextToCode[`${this.formModel.provinceName}`][
                  `${this.formModel.cityName}`
                ][`${this.formModel.districtName}`].code,
              ];
              // 组装融资方式
              this.formModel.loanMethod = this.formModel.loanMethod.includes(
                ","
              )
                ? +this.formModel.loanMethod.split(",")[0]
                : +this.formModel.loanMethod;

              this.pageType = "edit";
            });
          break;
        case "3":
          this.modalType = "revoke";
          this.visible = true;
          break;
        case "4":
          this.modalType = "del";
          this.visible = true;
          break;
        case "5":
          this.modalType = "finish";
          this.visible = true;
          break;
      }
    },
    handleCancel() {
      this.visible = false;
    },
    handleConfirm() {
      if (this.modalType == "del") {
        if (this.pageParams.pageNum != 1 && this.tableData.length == 1) {
          this.pageParams.pageNum = this.pageParams.pageNum - 1;
        }
        api
          .deleteServiceFunder({
            funderId: this.currentRow.funderId,
          })
          .then((res) => {
            this.$message.success("删除成功");
            this.getData({ ...this.pageParams, ...this.queryForm });
          });
      } else if (this.modalType == "revoke") {
        api
          .revokeServiceFunder({
            funderId: this.currentRow.funderId,
          })
          .then((res) => {
            this.$message.success("撤回成功");
            this.getData({ ...this.pageParams, ...this.queryForm });
          });
      } else {
        api
          .finishServiceFunder({
            funderId: this.currentRow.funderId,
          })
          .then((res) => {
            this.$message.success("完结成功");
            this.getData({ ...this.pageParams, ...this.queryForm });
          });
      }
    },
    addList() {
      Object.keys(this.formModel).forEach((item) => {
        this.formModel[item] = "";
      });
      this.selectedOptions = [];
      // this.formModel.loanMethod = [];
      this.pageType = "add";
    },
    handleBeforeUpload(file) {
      if (file.type.split("/")[0] != "image") {
        this.$message.error("请上传图片格式文件");
        return false;
      }
      if (file.size > 2097152) {
        this.$message.error("上传图片大小不能超出2M");
        return false;
      }
    },
    uploadOss(file) {
      let formData = new FormData();
      let token = setToken.getToken();
      formData.append("file", file.file, file.file.name);
      this.$http({
        method: "post",
        url: "/api/upload",
        data: formData,
        headers: { Authorization: "Bearer " + token },
      })
        .then((res) => {
          this.formModel.funderLogo = res.data.data;
          this.$refs["formModel"].validateField("funderLogo");
        })
        .catch((error) => {
          this.$message.error("系统错误");
        });
    },
    handleChange(value) {
      this.formModel.provinceName = CodeToText[`${value[0]}`];
      this.formModel.cityName = CodeToText[`${value[1]}`];
      this.formModel.districtName = CodeToText[`${value[2]}`];
    },
    adjustMaxLen(el, maxlength = 8) {
      el.target.value = el.target.value.replace(/^(\d+)\.(\d\d).*$/, "$1.$2"); //只能输入2个小数
      el.target.value = el.target.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符，只能输入正整数
      el.target.value = el.target.value.replace(/^\./g, ""); //验证第一个字符是数字而不是其他的
      el.target.value = el.target.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
      el.target.value = el.target.value
        .replace(".", "$#$")
        .replace(/\./g, "")
        .replace("$#$", "."); //保证.只出现一次，而不能出现两次以上

      if (el.target.value.length > maxlength) {
        if (!el.target.value.includes(".")) {
          this.formModel.loanAmount = el.target.value.slice(0, 8);
        } else {
          this.formModel.loanAmount = el.target.value.slice(0, 11);
        }
      } else {
        if (el.target.value.includes(".")) {
          el.target.value = el.target.value.slice(0, el.target.value.length);
          this.formModel.loanAmount = el.target.value.slice(
            0,
            el.target.value.length
          );
        }
      }
    },
    radioChange(val) {
      this.formRules.incomeMethod[0].required = true;
      this.formRules.exitMethod[0].required = true;
      this.$refs["formModel"].clearValidate(["exitMethod", "incomeMethod"]);
      if (val == 1) {
        this.formRules.incomeMethod[0].message = "请输入收益方式";
        this.formRules.exitMethod[0].message = "请选择退出方式";
      } else if (val === 2) {
        this.formRules.incomeMethod[0].message = "请输入资金利率";
        this.formRules.exitMethod[0].message = "请选择还款方式";
      } else {
        this.formRules.incomeMethod[0].required = false;
        this.formRules.exitMethod[0].required = false;
      }
      this.formModel.exitMethod = this.formModel.incomeMethod = "";
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$store.commit("setSubLoading", true);
          if (this.pageType == "add") {
            api.addServiceFunder(this.formModel).then((res) => {
              this.$message.success("添加成功");
              this.pageParams.pageNum = 1;
              this.getData();
            });
          } else {
            api
              .modifyServiceFunder({
                ...this.formModel,
                ...{ funderId: this.currentRow.funderId },
              })
              .then((res) => {
                this.$message.success("修改成功");
                this.getData();
              });
          }
        } else {
          return false;
        }
      });
    },
    closeForm(formName) {
      this.$refs[formName].resetFields();
      this.pageType = "list";
    },
  },
};
</script>
<style lang="less" scoped>
.capital-page {
  .form {
    .el-input,
    .el-cascader,
    .el-select {
      width: 600px !important;
    }
  }
}
</style>